const jwt = require('jsonwebtoken');
const config = require('../../config/auth.js');

const generateToken = (user) => {
  return jwt.sign(
    { id: user._id, role: user.role },
    config.secret,
    { expiresIn: config.expiresIn }
  );
};

const verifyToken = (token) => {
  return jwt.verify(token, config.secret);
};

module.exports = { generateToken, verifyToken };